/**
 * 
 */
package com.bms.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.bms.Logic;
import com.bms.abstracts.RESTController;
import com.bms.domain.Event;

/**
 * @author IBM
 *
 */
public class TaskListController extends RESTController {
	
	private Logic logic;
	
	public void setLogic(Logic logic) {
		this.logic = logic;
	}

	/* (non-Javadoc)
	 * @see com.bms.abstracts.RESTController#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ModelAndView doGet(HttpServletRequest request,
			HttpServletResponse response) {
		
		List<Event> list = logic.getGongZuoJiHuaList();
		
		String start = request.getParameter("start");
		String end = request.getParameter("end");
		String groups = request.getParameter("groups");
		
		
		
		if(!start.equals("") && end.equals("") && groups.equals("")){
			list = logic.getGongZuoJiHuaListFromStart(start);
		}
		
		if(!start.equals("") && !end.equals("") && groups.equals("")){
			list = logic.getGongZuoJiHuaListFromStartAndEnd(start,end);
		}
		
		if(!start.equals("") && end.equals("") && !groups.equals("")){
			list = logic.getGongZuoJiHuaListFromStartAndGroups(start,groups);
		}
		
		if(start.equals("") && end.equals("") && !groups.equals("")){
			list = logic.getGongZuoJiHuaListFromGroups(groups);
		}
		
		if(start.equals("") && !end.equals("") && !groups.equals("")){
			list = logic.getGongZuoJiHuaListFromEndAndGroups(end,groups);
			
		}
		
		if(start.equals("") && !end.equals("") && groups.equals("")){
			list = logic.getGongZuoJiHuaListFromEnd(end);
			
		}
		
		return new ModelAndView("taskList","list",list);
	}

	/* (non-Javadoc)
	 * @see com.bms.abstracts.RESTController#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ModelAndView doPost(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		return null;
	}

}
